<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
</head>
<body>
    <header class="aui-bar aui-bar-nav aui-bar-warning" id="aui-header">
        <a class="aui-btn aui-btn-warning aui-pull-left" tapmode onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">弹出框（Dialog）</div>
        <a class="aui-iconfont aui-icon-menu aui-pull-right"></a>
    </header>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    function closeWin(){
        api.closeWin();
    }
    apiready = function(){
        api.parseTapmode();
        var header = $api.byId('aui-header');
        $api.fixStatusBar(header); 
        var headerPos = $api.offset(header);
        var body_h = $api.offset($api.dom('body')).h;
        api.openFrame({
            name: 'dialog_frm',
            url: 'dialog_frm.html',
            bounces: false,
            rect: {
                x: 0,
                y: headerPos.h,
                w: headerPos.w,
                h: 'auto'
            }
        })
        api.addEventListener({
            name: 'dialogEvent'
        }, function(ret, err){
            if(ret.value.type=="show"){
                // slidBackEnabled
                if(api.systemType=='ios'){
                    api.setWinAttr({
                        slidBackEnabled: false
                    });
                }
                if(!$api.dom(".aui-mask")){
                    $api.append($api.dom("body"),'<div class="aui-mask"></div>');
                }
            }else if(ret.value.type=="hidden"){
                if(api.systemType=='ios'){
                    api.setWinAttr({
                        slidBackEnabled: true
                    });
                }
                $api.remove($api.dom(".aui-mask"));
            }
        });
        
    };
</script>
</html>